﻿using System;
using System.Configuration;

using MSAcademic.v2.Infrastructure.Article;
using MSAcademic.v2.Infrastructure.Picture;

namespace MSAcademic.v2.Web.Areas.Admin.Models.Picture
{
    public partial class EditArticleBigPictureViewModel
    {
        public int ArticleId { get; set; }
        public string OriginalUrl { get; set; }
        public string CroppedBigPictureUrl { get; set; }

        public double BigPictureWidth
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings["ArticleBigPictureWidth"]); }
        }

        public double BigPictureHeight
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings["ArticleBigPictureHeight"]); }
        }
    }
    public partial class EditArticleBigPictureViewModel
    {
        public string BigPictureUrl
        {
            get
            {
                if (_bigPictureUrl == null)
                {
                    _bigPictureUrl = new Lazy<string>(() =>_iPictureService.GetOriginalPictureUrl( _iArticleQueries.GetArticle(this.ArticleId).PictureUrlBig));
                }
                return _bigPictureUrl.Value;
            }
        }
        private Lazy<string> _bigPictureUrl;
    }
    public partial class EditArticleBigPictureViewModel
    {
         private readonly IArticleQueries _iArticleQueries;
         private readonly IPictureService _iPictureService;
         public EditArticleBigPictureViewModel(IArticleQueries iArticleQueries, IPictureService iPictureService)
         {
            _iArticleQueries = iArticleQueries;
            _iPictureService = iPictureService;
         }
        public EditArticleBigPictureViewModel()
        {
            
        }
    }
}